package org.csu.myblogger.myblogger.commom;

import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;

public class CommonResponce<T> implements Serializable {
    private int status;
    private T date;
    private String msg;

    private CommonResponce(int status,String msg){
        this.status=status;
        this.msg=msg;
    }
    private CommonResponce(int status,T date){
        this.status=status;
        this.date=date;
    }
    private CommonResponce(String msg,T date){
        this.date=date;
        this.msg=msg;
    }
    private CommonResponce(int status,String msg,T date){
        this.date=date;
        this.msg=msg;
        this.status=status;
    }

    //方法
    public static <T>CommonResponce<T> CreatForSuccess(String msg){
        return new CommonResponce<T>(ResponseCode.SUCCESS.getCcode(),msg);
    }
    public static <T>CommonResponce<T>CreatForSuccess(String msg,T data){
        return new CommonResponce<T>(msg,data);
    }
    public static <T>CommonResponce<T> CreatForSuccess(T data){
        return new CommonResponce<T>(ResponseCode.SUCCESS.getCcode(),data);
    }
    public static <T>CommonResponce<T> CreatForSuccess( int code,String msg,T data){
        return new CommonResponce<T>(code,msg,data);
    }

    //错误响应
    public static <T>CommonResponce<T> createForError(){
        return new CommonResponce<T>(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDescription());
    }
    public static <T>CommonResponce<T>createForError(int code,String msg){
        return new CommonResponce<T>(code,msg);
    }
    public static <T>CommonResponce<T>createForError(int code,T data){
        return new CommonResponce<T>(code,data);
    }
    public static <T>CommonResponce<T>createForError(int code,String msg,T data){
        return new CommonResponce<T>(code,msg,data);
    }
}
